#ifndef BLDC_FOC_H
#define BLDC_FOC_H
#include "ht32f5xxxx_01.h"
#include "usart.h"
#include "bldc_communicate.h"

/**********************************/
#define BLDC_STATUS_MASK (1<<4)
#define BLDC_STATUS_RUN  (1<<4)
#define BLDC_STATUS_STOP (0<<4)

#define BLDC_MODE_MASK   (3)
#define BLDC_MODE_POSIT  0
#define BLDC_MODE_SPEED  1
#define BLDC_MODE_MOMET  2
/**********************************/

#define RS485_SetRunMode(x) \
                        BLDC_RS485_SendCommand('p',device); \
                        BLDC_RS485_SendCommand(x,device);   \
                        BLDC_RS485_SendCommand('e',device)

typedef enum{BLDC_RunMode_Position, BLDC_RunMode_Speed, BLDC_RunMode_Moment}BLDC_RunMode_TypeDef;

int BLDC_Run(BLDC_Device *device);
int BLDC_Stop(BLDC_Device *device);
int BLDC_SetOrigin(BLDC_Device *device);
int BLDC_SetParam(BLDC_Device *device);
int BLDC_GetParam(BLDC_Device *device);
int BLDC_SetRunMode(BLDC_Device *device, BLDC_RunMode_TypeDef runmode);
int BLDC_SendParam(BLDC_Device *device);
int BLDC_Initialize(BLDC_Device *device);

extern int (*BLDC_ParamInquire)(BLDC_Device*);
extern BLDC_RequestStatusTypeDef BLDC_RequestStatus;
extern BLDC_Device BLDC_Elbow;
extern BLDC_Device BLDC_Swing;

/*****************Kd & Kp******************/
#define BLDC_Elbow_PositionMode_Kd 0xfff
#define BLDC_Elbow_PositionMode_Kp 0xfff
#define BLDC_Swing_PositionMode_Kd 0xfff
#define BLDC_Swing_PositionMode_Kp 0xfff
/******************************************/



#endif
